home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / bin / mk_cmds < prev    next >
Text File  |  2005-10-13  |  949b  |  50 lines

  1. #!/bin/sh
  2. #
  3. #
  4.  
  5. export LC_ALL=C
  6. DIR="${DIR-/usr/share/ss}"
  7. SS_DIR="/var/tmp/portage/ss-1.38/work/e2fsprogs-1.38/lib/ss"
  8. AWK=gawk
  9. SED=/bin/sed
  10.  
  11. if test "x$1" = x ; then
  12.     echo "Usage: mk_cmds file"
  13.     exit 1
  14. fi
  15.  
  16. if test -n "$_SS_DIR_OVERRIDE" ; then
  17.     DIR="$_SS_DIR_OVERRIDE";
  18. fi
  19.  
  20. if test ! -f $DIR/ct_c.sed || test ! -f $DIR/ct_c.awk ; then
  21.     DIR="$SS_DIR"
  22. #    echo "Falling back to $DIR..."
  23.     if test ! -f "$DIR/ct_c.sed" || test ! -f "$DIR/ct_c.awk" ; then
  24.     echo "mk_cmds: Couldn't find mk_cmds's template files."
  25.     exit 1
  26.     fi
  27. fi
  28.  
  29. FILE="$1"
  30. ROOT=`echo $1 | sed -e s/.ct$//`
  31. BASE=`basename "$ROOT"`
  32. TMP="ct$$.c"
  33.  
  34. if test ! -f "$FILE" ; then
  35.     echo "$FILE: File not found"
  36.     exit 1;
  37. fi
  38.  
  39. ${SED} -f "${DIR}/ct_c.sed"  "${FILE}" \
  40.     | ${AWK} -f "${DIR}/ct_c.awk" "rootname=${ROOT}" "outfile=${TMP}" -
  41.  
  42. if grep "^#__ERROR_IN_FILE" "${TMP}" > /dev/null; then
  43.     rm "${TMP}"
  44.     exit 1
  45. else
  46.     rm -f "${BASE}.c"
  47.     mv "${TMP}" "${BASE}.c"
  48.     exit 0
  49. fi
  50.